package com.hrs.core.controller;

import com.hrs.common.anno.NoValidPrivilege;
import com.hrs.common.constant.SwaggerConst;
import com.hrs.common.result.Result;
import com.hrs.core.service.PayOrderService;
import com.hrs.enity.dto.PayLogRegisterDto;
import com.hrs.enity.dto.PayLogViewDto;
import com.hrs.enity.dto.PayOrderViewDto;
import com.hrs.enity.ro.PayOrderListRo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 摆渡人
 * @description
 * @date 2023/1/13 10:10
 */
@Api(tags = {SwaggerConst.Admin.MANAGER_PAY})
@RestController
public class PayController {

    @Autowired
    public PayOrderService payOrderService;

    @ApiOperation(value = "生成本月薪酬数据")
    @PostMapping("/pay/init")
    public Result<String> initPay() {
        return payOrderService.initPay();
    }

    @ApiOperation(value = "发放单列表")
    @PostMapping("/pay/order/list")
    public Result<List<PayOrderViewDto>> listPayOrder(@Validated @RequestBody PayOrderListRo payOrderListRo) {
        return payOrderService.listPayOrder(payOrderListRo);
    }

    @ApiOperation(value = "某个发放单详情")
    @GetMapping("/pay/log/list/{orderId}")
    @NoValidPrivilege
    public Result<List<PayLogViewDto>> listPayLog(@PathVariable Long orderId){
        return payOrderService.listPayLog(orderId);
    }

    @ApiOperation(value = "登记明细")
    @PostMapping("/pay/log/register")
    public Result<String> registerLog(@Validated @RequestBody PayLogRegisterDto logRegisterDto) {
        return payOrderService.registerLog(logRegisterDto);
    }

    @ApiOperation(value = "审核")
    @PostMapping("/pay/log/review")
    public Result<String> reviewLog(@Validated @RequestBody PayLogRegisterDto logRegisterDto) {
        return payOrderService.reviewLog(logRegisterDto);
    }
}
